package com.liumingtai.learn.shiro.utils;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.SignatureAlgorithm;

import javax.crypto.SecretKey;
import java.util.HashMap;

public class TokenUtil {

    private static final SignatureAlgorithm JWT_ALG = SignatureAlgorithm.HS256;




    public static String createToken(HashMap<String, Object> userInfo) {
        String token = JwtHelper.buildJWT("123", userInfo);
        return token;
    }

    public static Claims  parseToken(String token) {
        SecretKey key = JwtHelper.generateKey(JwtHelper.JWT_ALG, JwtHelper.JWT_RULE);
        Jws<Claims> claimsJws = JwtHelper.parseJWT(key,token);
        Claims body = claimsJws.getBody();
        return body;
    }
}
